﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Etapa1.SofRender
{
    public static class ShaderOp
    {
        
        public static Vector4 reflect(Vector4 v1 , Vector4 v2 )
        {
             Vector3 vv1 = ShaderOp.toVector3(v1);
             Vector3 vv2 = ShaderOp.toVector3(v2);
             return ShaderOp.toVector4(Vector3.Reflect(vv1, vv2));            
        }
        public static Vector3 reflect(Vector3 v1, Vector3 v2)
        {            
            return Vector3.Reflect(v1, v2);
        }


        public static float pow(float v0, float v1)
        {
            return (float) Math.Pow(v0, v1);
        }

        public static float saturate(float val)
        {
            if (val > 1)
                val = 1;
            if (val < 0)
                val = 0;

            return val;
        }

        public static float dot(Vector4 v1, Vector4 v2)
        {
            return Vector3.Dot(toVector3(v1), toVector3(v2));
        }

        public static float dot(Vector3 v1, Vector3 v2)
        {
            return Vector3.Dot(v1, v2);
        }    
    
        public static Vector4 Normalize(Vector4 vector)
        {
            return toVector4(Vector3.Normalize(toVector3(vector)));
        }

        public static Vector3 Normalize(Vector3 vector)
        {
            return Vector3.Normalize(vector);
        }

        public static Vector4 NormalizeNorm(Vector4 vector)
        {
            return toVector4Norm(Vector3.Normalize(toVector3(vector)));
        }

        public static Vector3 toVector3(Vector4 vec)
        {
            return new Vector3(vec.X, vec.Y, vec.Z);
        }

        public static Vector4 toVector4(Vector3 vec)
        {
            return new Vector4(vec.X, vec.Y, vec.Z,1);
        }
        public static Vector4 toVector4(Vector2 vec)
        {
            return new Vector4(vec.X, vec.Y, 0, 0);
        }
        public static Vector4 toVector4Norm(Vector3 vec)
        {
            return new Vector4(vec.X, vec.Y, vec.Z, 0);
        }
    }
}
